package com.squid.dataCenter.controller;

import com.squid.base.common.bean.Return;
import com.squid.dataCenter.model.req.datadictionaryparent.DataDictionaryParentInsertReq;
import com.squid.dataCenter.model.req.datadictionaryparent.DataDictionaryParentUpdateReq;
import com.squid.dataCenter.model.resp.datadictionaryparent.DataDictionaryParentResp;
import com.squid.dataCenter.service.datadictionaryparent.DataDictionaryParentService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据字典控制器
 *
 * @author jinhang1
 * @date 2024/06/26
 */
@RestController
@RequestMapping("/dataDictionaryParent")
public class DataDictionaryParentController {
    @Resource
    DataDictionaryParentService dataDictionaryParentService;

    @PostMapping("/page")
    public Return<List<DataDictionaryParentResp>> page() {
        List<DataDictionaryParentResp> response = dataDictionaryParentService.selectDataDicParentList();
        return Return.<List<DataDictionaryParentResp>>success().data(response);
    }

    @PostMapping("/add")
    public Return<Object> add(@RequestBody DataDictionaryParentInsertReq req) {
        dataDictionaryParentService.add(req);
        return Return.success();
    }

    @PostMapping("/update")
    public Return<Object> update(@RequestBody DataDictionaryParentUpdateReq req) {
        dataDictionaryParentService.update(req);
        return Return.success();
    }

    @PostMapping("/delete")
    public Return<Object> delete(@RequestBody Long id) {
        dataDictionaryParentService.delete(id);
        return Return.success();
    }

}
